<template>
	<view class="">
		<template v-if="isGrid">
			<view class="flex flex-column u-m-b-20 rounded-10 bg-white overflow-hidden" @click="toGoodsDetail(item.id)">
				<u-image class="border" :src="item.image" width="340rpx" height="340rpx"></u-image>
				<view class="flex flex-column u-p-x-20 u-p-t-20">
					<text class="u-font-26 text-ellipsis-2" style="height: 75rpx; width: 300rpx;">{{item.goods_name}}</text>
					<text class="u-p-y-10 u-font-30 font-weight-bold text-danger">¥ {{item[price]}}</text>
					<view class="flex align-center justify-between u-p-b-20">
						<view class="u-m-r-30" v-if="item.merch_id == 0">
							<u-tag type="dark" text="自营" size="mini" :bgColor="'#ff9c58'" color="#fff" ></u-tag>
						</view>
					  <text class="" style="color: #bfbfbf;">已售{{item.goods_sales }}件</text>
					</view>
				</view>
			</view>
		</template>
		<template v-if="!isGrid">
			<view class="flex u-p-20 u-m-b-20 bg-white rounded-10" @click="toGoodsDetail(item.id)">
				<u-image class="border" borderRadius="5" :src="item.image" width="180rpx" height="180rpx"></u-image>
				<view class="flex-1 flex flex-column justify-between u-p-x-20">
					<text class="u-font-28 text-ellipsis-2" style="height: 80rpx; width: 450rpx;">{{item.goods_name}}</text>
					<text class="u-p-y-10 u-font-26 text-danger font-weight-bold">¥{{item.goods_min_price}}</text>
					<view class="flex align-center">
						<view class="u-m-r-30" v-if="item.merch_id == 0">
							<u-tag type="dark" text="自营" size="mini" :bgColor="'#ff9c58'" color="#fff" ></u-tag>
						</view>
					  <text class="">已售{{item.goods_sales}}件</text>
					</view>
				</view>
			</view>
		</template>
	</view>
	
</template>

<script>
	export default {
		name: 'dy-goods-item-list',
		props: {
			isGrid: {
				type: Boolean,
				default: true
			},
			item: {
				type: Object,
				default() {
					return {}
				}
			},
			price: {
				type:String,
				default: 'goods_min_price'
			}
		},
		data() {
			return {
				
			}
		},
		methods: {
			toGoodsDetail() {
			  uni.navigateTo({
			    url:'/pages/goodsDetail/commonGoodsDetail/commonGoodsDetail?goods_id='+ this.item.id
			  })
			}
		}
	}
</script>

<style>
</style>
